diff --git a/plugin/IMDbScrape/.gitignore b/plugin/IMDbScrape/.gitignore deleted file mode 100644 index 06361c9de..000000000 --- a/plugin/IMDbScrape/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.idea/ -cache/* -!cache/.gitkeep -cast/* -!cast/not-found.jpg -posters/* -!posters/not-found.jpg -vendor/ diff --git a/plugin/IMDbScrape/IMDbScrape.php b/plugin/IMDbScrape/IMDbScrape.php deleted file mode 100644 index 5d9a2a826..000000000 --- a/plugin/IMDbScrape/IMDbScrape.php +++ /dev/null @@ -1,67 +0,0 @@ -Your Video title must match with IMDb title
Help"; - } - - public function getName() { - return "IMDbScrape"; - } - - public function getUUID() { - return "21171156-dc62-46e3-ace9-86c6e8f9c81b"; - } - - public function getPluginVersion() { - return "1.0"; - } - - public function getVideosManagerListButton() { - global $global; - $btn = '
'; - $btn .= '
'; - $btn .= '
'; - $btn .= '
'; - $btn .= '
'; - return $btn; - } - - - public function getEmptyDataObject() { - global $global; - $obj = new stdClass(); - $obj->posterWidth = 186; - $obj->posterHeight = 279; - $obj->encodeTrailerInWebm = false; - return $obj; - } - - public function getFooterCode() { - global $global; - if (basename($_SERVER["SCRIPT_FILENAME"]) === 'managerVideos.php') { - include $global['systemRootPath'] . 'plugin/IMDbScrape/footer.php'; - } - } - -} diff --git a/plugin/IMDbScrape/cache/.gitkeep b/plugin/IMDbScrape/cache/.gitkeep deleted file mode 100644 index e1664421e..000000000 --- a/plugin/IMDbScrape/cache/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -.gitkeep diff --git a/plugin/IMDbScrape/cast/not-found.jpg b/plugin/IMDbScrape/cast/not-found.jpg deleted file mode 100644 index 302d25336..000000000 Binary files a/plugin/IMDbScrape/cast/not-found.jpg and /dev/null differ diff --git a/plugin/IMDbScrape/footer.php b/plugin/IMDbScrape/footer.php deleted file mode 100644 index 842d0dbdd..000000000 --- a/plugin/IMDbScrape/footer.php +++ /dev/null @@ -1,19 +0,0 @@ - \ No newline at end of file diff --git a/plugin/IMDbScrape/get.json.php b/plugin/IMDbScrape/get.json.php deleted file mode 100644 index e60ca9b67..000000000 --- a/plugin/IMDbScrape/get.json.php +++ /dev/null @@ -1,68 +0,0 @@ -error = true; -$obj->msg = ""; - -if (!User::isAdmin() && !Video::canEdit($_GET['videos_id'])) { - $obj->msg = "You cant do this"; - die(json_encode($obj)); -} - -$video = new Video('', '', $_GET['videos_id']); - -$oIMDB = new IMDB($video->getTitle()); -if ($oIMDB->isReady) { - $videoFileName = $video->getFilename(); - - if (empty($_GET['what']) || $_GET['what'] == 1) { - // get poster - $poster = $oIMDB->getPoster('big', true); - - $filename = Video::getPathToFile("{$videoFileName}_portrait.jpg"); - im_resizeV2($poster, $filename, $plugin->posterWidth, $plugin->posterHeight); - } - - if (empty($_GET['what']) || $_GET['what'] == 2) { - // get description - $description = $oIMDB->getDescription(); - $video->setDescription($description); - } - - if (empty($_GET['what']) || $_GET['what'] == 3) { - // get rate - $rate = $oIMDB->getRating(); - $video->setRate($rate); - } - - if (empty($_GET['what']) || $_GET['what'] == 4) { - $encodeTrailerInWebm = intval($plugin->encodeTrailerInWebm); - // trailer - $trailer = $oIMDB->getTrailerAsUrl(true); - $encoderURL = $config->getEncoderURL() . "youtubeDl.json?webm={$encodeTrailerInWebm}&videoURL=" . urlencode($trailer) . "&webSiteRootURL=" . urlencode($global['webSiteRootURL']) . "&user=" . urlencode(User::getUserName()) . "&pass=" . urlencode(User::getUserPass()); - _error_log("IMDB encoder URL {$encoderURL}"); - $json = url_get_contents($encoderURL); - _error_log("IMDB encoder answer {$json}"); - $json = _json_decode($json); - if (!empty($json->videos_id)) { - $trailerVideo = new Video('', '', $json->videos_id); - $trailerVideo->setStatus('u'); - $video->setTrailer1(Video::getPermaLink($json->videos_id, true)); - } - } - $video->save(); - - $obj->error = false; -} else { - $obj->msg = "Movie not found"; -} - -echo json_encode($obj); diff --git a/plugin/IMDbScrape/imdb.class.php b/plugin/IMDbScrape/imdb.class.php deleted file mode 100644 index 38a5c544d..000000000 --- a/plugin/IMDbScrape/imdb.class.php +++ /dev/null @@ -1,1684 +0,0 @@ - - * @license https://opensource.org/licenses/MIT The MIT License - * @link https://github.com/FabianBeiner/PHP-IMDB-Grabber/ GitHub Repository - * @version 6.1.4 - */ -class IMDB -{ - /** - * Set this to true if you run into problems. - */ - const IMDB_DEBUG = false; - - /** - * Set the preferred language for the User Agent. - */ - const IMDB_LANG = 'en-US,en;q=0.9'; - - /** - * Define the timeout for cURL requests. - */ - const IMDB_TIMEOUT = 15; - - /** - * These are the regular expressions used to extract the data. - * If you don’t know what you’re doing, you shouldn’t touch them. - */ - const IMDB_AKA = '~]*>\s*Also\s*Known\s*As\s*\s*(.+)~Uis'; - const IMDB_ASPECT_RATIO = '~]*>Aspect\s*Ratio\s*(.+)~Uis'; - const IMDB_AWARDS = '~\s*Awards:(.+)~Uis'; - const IMDB_BUDGET = '~]*>Budget<\/td>\s*\s*(.*)(?:\(estimated\))\s*<\/td>~Ui'; - const IMDB_CAST = '~]*itemprop="actor"[^>]*>\s*]*>\s*(.+)~Ui'; - const IMDB_RATING = '~class="ipl-rating-star__rating">(.*)<~Ui'; - const IMDB_RELEASE_DATE = '~href="/title/[t0-9]*/releaseinfo">(.*)<~Ui'; - const IMDB_RUNTIME = '~]*>\s*Runtime\s*\s*(.+)~Ui'; - const IMDB_SEARCH = '~ (?:.*)<\/a>~Ui'; - const IMDB_SEASONS = '~episodes\?season=(?:\d+)">(\d+)<~Ui'; - const IMDB_SOUND_MIX = '~]*>\s*Sound\s*Mix\s*\s*(.+)~Ui'; - const IMDB_TAGLINE = '~]*>\s*Taglines\s*\s*(.+)~Ui'; - const IMDB_TITLE = '~itemprop="name">(.*)(<\/h3>|'; - } - if (null !== $iCache && (int) $iCache > 0) { - $this->iCache = (int) $iCache; - } - $this->fetchUrl($sSearch); - } - - /** - * @param string $sSearch IMDb URL or movie title to search for. - * - * @return bool True on success, false on failure. - */ - private function fetchUrl($sSearch) - { - $sSearch = trim($sSearch); - - // Try to find a valid URL. - $sId = IMDBHelper::matchRegex($sSearch, self::IMDB_ID, 1); - if (false !== $sId) { - $this->iId = preg_replace('~[\D]~', '', $sId); - $this->sUrl = 'https://www.imdb.com/title/tt' . $this->iId . '/reference'; - $bSearch = false; - } else { - switch (strtolower($this->sSearchFor)) { - case 'movie': - $sParameters = '&s=tt&ttype=ft'; - break; - case 'tv': - $sParameters = '&s=tt&ttype=tv'; - break; - case 'episode': - $sParameters = '&s=tt&ttype=ep'; - break; - case 'game': - $sParameters = '&s=tt&ttype=vg'; - break; - default: - $sParameters = '&s=tt'; - } - - $this->sUrl = 'https://www.imdb.com/find?q=' . str_replace(' ', '+', $sSearch) . $sParameters; - $bSearch = true; - - // Was this search already performed and cached? - $sRedirectFile = $this->sRoot . '/cache/' . sha1($this->sUrl) . '.redir'; - if (is_readable($sRedirectFile)) { - if (self::IMDB_DEBUG) { - echo '
Using redirect: ' . basename($sRedirectFile) . '
'; - } - $sRedirect = file_get_contents($sRedirectFile); - $this->sUrl = trim($sRedirect); - $this->iId = preg_replace('~[\D]~', '', IMDBHelper::matchRegex($sRedirect, self::IMDB_ID, 1)); - $bSearch = false; - } - } - - // Does a cache of this movie exist? - $sCacheFile = $this->sRoot . '/cache/' . sha1($this->iId) . '.cache'; - if (is_readable($sCacheFile)) { - $iDiff = round(abs(time() - filemtime($sCacheFile)) / 60); - if ($iDiff < $this->iCache) { - if (true === self::IMDB_DEBUG) { - echo '
Using cache: ' . basename($sCacheFile) . '
'; - } - $this->sSource = file_get_contents($sCacheFile); - $this->isReady = true; - - return true; - } - } - - // Run cURL on the URL. - if (true === self::IMDB_DEBUG) { - echo '
Running cURL: ' . $this->sUrl . '
'; - } - - $aCurlInfo = IMDBHelper::runCurl($this->sUrl); - $sSource = $aCurlInfo['contents']; - - if (false === $sSource) { - if (true === self::IMDB_DEBUG) { - echo '
cURL error: ' . var_dump($aCurlInfo) . '
'; - } - - return false; - } - - // Was the movie found? - $sMatch = IMDBHelper::matchRegex($sSource, self::IMDB_SEARCH, 1); - if (false !== $sMatch) { - $sUrl = 'https://www.imdb.com/title/' . $sMatch . '/reference'; - if (true === self::IMDB_DEBUG) { - echo '
New redirect saved: ' . basename($sRedirectFile) . ' => ' . $sUrl . '
'; - } - file_put_contents($sRedirectFile, $sUrl); - $this->sSource = null; - self::fetchUrl($sUrl); - - return true; - } - $sMatch = IMDBHelper::matchRegex($sSource, self::IMDB_NOT_FOUND, 0); - if (false !== $sMatch) { - if (true === self::IMDB_DEBUG) { - echo '
Movie not found: ' . $sSearch . '
'; - } - - return false; - } - - $this->sSource = str_replace([ - "\n", - "\r\n", - "\r" - ], - '', - $sSource); - $this->isReady = true; - - // Save cache. - if (false === $bSearch) { - if (true === self::IMDB_DEBUG) { - echo '
Cache created: ' . basename($sCacheFile) . '
'; - } - file_put_contents($sCacheFile, $this->sSource); - } - - return true; - } - - /** - * @return array All data. - */ - public function getAll() - { - $aData = []; - foreach (get_class_methods(__CLASS__) as $method) { - if (substr($method, 0, 3) === 'get' && $method !== 'getAll' && $method !== 'getCastImages') { - $aData[$method] = [ - 'name' => ltrim($method, 'get'), - 'value' => $this->{$method}() - ]; - } - } - array_multisort($aData); - - return $aData; - } - - /** - * @return string “Also Known As” or $sNotFound. - */ - public function getAka() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_AKA, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * Returns all local names - * - * @return string All local names. - */ - public function getAkas() - { - if (true === $this->isReady) { - // Does a cache of this movie exist? - $sCacheFile = $this->sRoot . '/cache/' . sha1($this->iId) . '_akas.cache'; - $bUseCache = false; - - if (is_readable($sCacheFile)) { - $iDiff = round(abs(time() - filemtime($sCacheFile)) / 60); - if ($iDiff < $this->iCache || false) { - $bUseCache = true; - } - } - - if ($bUseCache) { - $aRawReturn = file_get_contents($sCacheFile); - $aReturn = unserialize($aRawReturn); - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } else { - $fullAkas = sprintf('https://www.imdb.com/title/tt%s/releaseinfo', $this->iId); - $aCurlInfo = IMDBHelper::runCurl($fullAkas); - $sSource = $aCurlInfo['contents']; - - if (false === $sSource) { - if (true === self::IMDB_DEBUG) { - echo '
cURL error: ' . var_dump($aCurlInfo) . '
'; - } - - return false; - } - - $aReturned = IMDBHelper::matchRegex($sSource, "~(.*?)<\/td>\s+(.*?)<\/td>~"); - - if ($aReturned) { - $aReturn = []; - foreach ($aReturned[1] as $i => $strName) { - if (strpos($strName, '(') === false) { - $aReturn[] = [ - 'title' => IMDBHelper::cleanString($aReturned[2][$i]), - 'country' => IMDBHelper::cleanString($strName) - ]; - } - } - - file_put_contents($sCacheFile, serialize($aReturn)); - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string “Aspect Ratio” or $sNotFound. - */ - public function getAspectRatio() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_ASPECT_RATIO, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string The awards of the movie or $sNotFound. - */ - public function getAwards() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_AWARDS, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param int $iLimit How many cast members should be returned? - * @param bool $bMore Add … if there are more cast members than printed. - * @param string $sTarget Add a target to the links? - * - * @return string A list with linked cast members or $sNotFound. - */ - public function getCastAsUrl($iLimit = 0, $bMore = true, $sTarget = '') - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_CAST); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - if (0 !== $iLimit && $i >= $iLimit) { - break; - } - $aReturn[] = - '
' . - IMDBHelper::cleanString($sName) . - ''; - } - - $bHaveMore = ($bMore && (count($aMatch[2]) > $iLimit)); - - return IMDBHelper::arrayOutput($this->bArrayOutput, - $this->sSeparator, - self::$sNotFound, - $aReturn, - $bHaveMore); - } - } - - return self::$sNotFound; - } - - /** - * @param int $iLimit How many cast members should be returned? - * @param bool $bMore Add … if there are more cast members than printed. - * - * @return string A list with cast members or $sNotFound. - */ - public function getCast($iLimit = 0, $bMore = true) - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_CAST); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - if (0 !== $iLimit && $i >= $iLimit) { - break; - } - $aReturn[] = IMDBHelper::cleanString($sName); - } - - $bMore = (0 !== $iLimit && $bMore && (count($aMatch[2]) > $iLimit) ? '…' : ''); - - $bHaveMore = ($bMore && (count($aMatch[2]) > $iLimit)); - - return IMDBHelper::arrayOutput($this->bArrayOutput, - $this->sSeparator, - self::$sNotFound, - $aReturn, - $bHaveMore); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @param int $iLimit How many cast images should be returned? - * @param bool $bMore Add … if there are more cast members than printed. - * @param string $sSize small, mid or big cast images - * @param bool $bDownload Return URL or Download - * - * @return array Array with cast name as key, and image as value. - */ - public function getCastImages($iLimit = 0, $bMore = true, $sSize = 'small', $bDownload = false) - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_CAST_IMAGE); - $aReturn = []; - if (count($aMatch[4])) { - foreach ($aMatch[4] as $i => $sName) { - if (0 !== $iLimit && $i >= $iLimit) { - break; - } - $sMatch = $aMatch[2][$i]; - - if ('big' === strtolower($sSize) && false !== strstr($aMatch[2][$i], '@._')) { - $sMatch = substr($aMatch[2][$i], 0, strpos($aMatch[2][$i], '@._')) . '@.jpg'; - } elseif ('mid' === strtolower($sSize) && false !== strstr($aMatch[2][$i], '@._')) { - $sMatch = substr($aMatch[2][$i], 0, strpos($aMatch[2][$i], '@._')) . '@._V1_UX214_AL_.jpg'; - } - - if (false === $bDownload) { - $sMatch = IMDBHelper::cleanString($sMatch); - } else { - $sLocal = IMDBHelper::saveImageCast($sMatch, $aMatch[3][$i]); - if (file_exists(dirname(__FILE__) . '/' . $sLocal)) { - $sMatch = $sLocal; - } else { - //the 'big' image isn't available, try the 'mid' one (vice versa) - if ('big' === strtolower($sSize) && false !== strstr($aMatch[2][$i], '@._')) { - //trying the 'mid' one - $sMatch = - substr($aMatch[2][$i], 0, strpos($aMatch[2][$i], '@._')) . '@._V1_UX214_AL_.jpg'; - } else { - //trying the 'big' one - $sMatch = substr($aMatch[2][$i], 0, strpos($aMatch[2][$i], '@._')) . '@.jpg'; - } - - $sLocal = IMDBHelper::saveImageCast($sMatch, $aMatch[3][$i]); - if (file_exists(dirname(__FILE__) . '/' . $sLocal)) { - $sMatch = $sLocal; - } else { - $sMatch = IMDBHelper::cleanString($aMatch[2][$i]); - } - } - } - - $aReturn[IMDBHelper::cleanString($aMatch[4][$i])] = $sMatch; - } - - $bMore = (0 !== $iLimit && $bMore && (count($aMatch[4]) > $iLimit) ? '…' : ''); - - $bHaveMore = ($bMore && (count($aMatch[4]) > $iLimit)); - - $aReturn = array_replace($aReturn, - array_fill_keys(array_keys($aReturn, self::$sNotFound), - 'cast/not-found.jpg')); - - return $aReturn; - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @param int $iLimit How many cast members should be returned? - * @param bool $bMore Add … if there are more cast members than - * printed. - * @param string $sTarget Add a target to the links? - * - * @return string A list with linked cast members and their character or - * $sNotFound. - */ - public function getCastAndCharacterAsUrl($iLimit = 0, $bMore = true, $sTarget = '') - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_CAST); - $aMatchChar = IMDBHelper::matchRegex($this->sSource, self::IMDB_CHAR); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - if (0 !== $iLimit && $i >= $iLimit) { - break; - } - $aReturn[] = - '' . - IMDBHelper::cleanString($sName) . - ' as ' . - IMDBHelper::cleanString($aMatchChar[1][$i]); - } - - $bHaveMore = ($bMore && (count($aMatch[2]) > $iLimit)); - - return IMDBHelper::arrayOutput($this->bArrayOutput, - $this->sSeparator, - self::$sNotFound, - $aReturn, - $bHaveMore); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @param int $iLimit How many cast members should be returned? - * @param bool $bMore Add … if there are more cast members than printed. - * - * @return string A list with cast members and their character or - * $sNotFound. - */ - public function getCastAndCharacter($iLimit = 0, $bMore = true) - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_CAST); - $aMatchChar = IMDBHelper::matchRegex($this->sSource, self::IMDB_CHAR); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - if (0 !== $iLimit && $i >= $iLimit) { - break; - } - $aReturn[] = IMDBHelper::cleanString($sName) . ' as ' . IMDBHelper::cleanString($aMatchChar[1][$i]); - } - - $bHaveMore = ($bMore && (count($aMatch[2]) > $iLimit)); - - return IMDBHelper::arrayOutput($this->bArrayOutput, - $this->sSeparator, - self::$sNotFound, - $aReturn, - $bHaveMore); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string The certification of the movie or $sNotFound. - */ - public function getCertification() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_CERTIFICATION, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string Color or $sNotFound. - */ - public function getColor() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_COLOR, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string The company producing the movie or $sNotFound. - */ - public function getCompany() - { - if (true === $this->isReady) { - $sMatch = $this->getCompanyAsUrl(); - if (self::$sNotFound !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sTarget Add a target to the links? - * - * @return string The linked company producing the movie or $sNotFound. - */ - public function getCompanyAsUrl($sTarget = '') - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_COMPANY); - if (isset($aMatch[2][0])) { - return '' . - IMDBHelper::cleanString($aMatch[2][0]) . - ''; - } - } - - return self::$sNotFound; - } - - /** - * @return string A list with countries or $sNotFound. - */ - public function getCountry() - { - if (true === $this->isReady) { - $sMatch = $this->getCountryAsUrl(); - if (self::$sNotFound !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sTarget Add a target to the links? - * - * @return string A list with linked countries or $sNotFound. - */ - public function getCountryAsUrl($sTarget = '') - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_COUNTRY); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - $aReturn[] = - '' . - IMDBHelper::cleanString($sName) . - ''; - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string A list with the creators or $sNotFound. - */ - public function getCreator() - { - if (true === $this->isReady) { - $sMatch = $this->getCreatorAsUrl(); - if (self::$sNotFound !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sTarget Add a target to the links? - * - * @return string A list with the linked creators or $sNotFound. - */ - public function getCreatorAsUrl($sTarget = '') - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_CREATOR, 1); - $aMatch = IMDBHelper::matchRegex($sMatch, self::IMDB_NAME); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - $aReturn[] = - '' . - IMDBHelper::cleanString($sName) . - ''; - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string The description of the movie or $sNotFound. - */ - public function getDescription() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_DESCRIPTION, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string A list with the directors or $sNotFound. - */ - public function getDirector() - { - if (true === $this->isReady) { - $sMatch = $this->getDirectorAsUrl(); - if (self::$sNotFound !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sTarget Add a target to the links? - * - * @return string A list with the linked directors or $sNotFound. - */ - public function getDirectorAsUrl($sTarget = '') - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_DIRECTOR, 1); - $aMatch = IMDBHelper::matchRegex($sMatch, self::IMDB_NAME); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - $aReturn[] = - '' . - IMDBHelper::cleanString($sName) . - ''; - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string A list with the genres or $sNotFound. - */ - public function getGenre() - { - if (true === $this->isReady) { - $sMatch = $this->getGenreAsUrl(); - if (self::$sNotFound !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sTarget Add a target to the links? - * - * @return string A list with the linked genres or $sNotFound. - */ - public function getGenreAsUrl($sTarget = '') - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_GENRE); - $aReturn = []; - if (count($aMatch[2])) { - foreach (array_unique($aMatch[2]) as $i => $sName) { - $aReturn[] = - '' . - IMDBHelper::cleanString($sName) . - ''; - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string cumulative worldwide gross or $sNotFound. - */ - public function getGross() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_GROSS, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string A list with the languages or $sNotFound. - */ - public function getLanguage() - { - if (true === $this->isReady) { - $sMatch = $this->getLanguageAsUrl(); - if (self::$sNotFound !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sTarget Add a target to the links? - * - * @return string A list with the linked languages or $sNotFound. - */ - public function getLanguageAsUrl($sTarget = '') - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_LANGUAGE); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - $aReturn[] = - '' . - IMDBHelper::cleanString($sName) . - ''; - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string A list with the location or $sNotFound. - */ - public function getLocation() - { - if (true === $this->isReady) { - $sMatch = $this->getLocationAsUrl(); - if (self::$sNotFound !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sTarget Add a target to the links? - * - * @return string A list with the linked location or $sNotFound. - */ - public function getLocationAsUrl($sTarget = '') - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_LOCATION); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - $aReturn[] = - '' . - IMDBHelper::cleanString($sName) . - ''; - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string The MPAA of the movie or $sNotFound. - */ - public function getMpaa() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_MPAA, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string A list with the plot keywords or $sNotFound. - */ - public function getPlotKeywords() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_PLOT_KEYWORDS, 1); - if (false !== $sMatch) { - $aReturn = explode('|', IMDBHelper::cleanString($sMatch)); - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @param int $iLimit The limit. - * - * @return string The plot of the movie or $sNotFound. - */ - public function getPlot($iLimit = 0) - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_PLOT, 1); - if (false !== $sMatch) { - if ($iLimit !== 0) { - return IMDBHelper::getShortText(IMDBHelper::cleanString($sMatch), $iLimit); - } - - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sSize Small or big poster? - * @param bool $bDownload Return URL to the poster or download it? - * - * @return bool|string Path to the poster. - */ - public function getPoster($sSize = 'small', $bDownload = false) - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_POSTER, 1); - if (false !== $sMatch) { - if ('big' === strtolower($sSize) && false !== strstr($sMatch, '@._')) { - $sMatch = substr($sMatch, 0, strpos($sMatch, '@._')) . '@.jpg'; - } - if (false === $bDownload) { - return IMDBHelper::cleanString($sMatch); - } else { - $sLocal = IMDBHelper::saveImage($sMatch, $this->iId); - if (file_exists(dirname(__FILE__) . '/' . $sLocal)) { - return $sLocal; - } else { - return $sMatch; - } - } - } - } - - return self::$sNotFound; - } - - /** - * @return string The rating of the movie or $sNotFound. - */ - public function getRating() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_RATING, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * Release date doesn't contain all the information we need to create a media and - * we need this function that checks if users can vote target media (if can, it's released). - * - * @return true If the media is released - */ - public function isReleased() - { - $strReturn = $this->getReleaseDate(); - if ($strReturn == self::$sNotFound || $strReturn == 'Not yet released') { - return false; - } - - return true; - } - - /** - * @return string The release date of the movie or $sNotFound. - */ - public function getReleaseDate() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_RELEASE_DATE, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * Returns all local names - * - * @return string country - * @return string release date - */ - public function getReleaseDates() - { - if (true === $this->isReady) { - // Does a cache of this movie exist? - $sCacheFile = $this->sRoot . '/cache/' . sha1($this->iId) . '_akas.cache'; - $bUseCache = false; - - if (is_readable($sCacheFile)) { - $iDiff = round(abs(time() - filemtime($sCacheFile)) / 60); - if ($iDiff < $this->iCache || false) { - $bUseCache = true; - } - } - - if ($bUseCache) { - $aRawReturn = file_get_contents($sCacheFile); - $aReturn = unserialize($aRawReturn); - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } else { - $fullAkas = sprintf('https://www.imdb.com/title/tt%s/releaseinfo', $this->iId); - $aCurlInfo = IMDBHelper::runCurl($fullAkas); - $sSource = $aCurlInfo['contents']; - - if (false === $sSource) { - if (true === self::IMDB_DEBUG) { - echo '
cURL error: ' . var_dump($aCurlInfo) . '
'; - } - - return false; - } - - $aReturned = - IMDBHelper::matchRegex($sSource, '~>(.*)<\/a><\/td>\s+(.*)<\/td>~'); - - if ($aReturned) { - $aReturn = []; - foreach ($aReturned[1] as $i => $strName) { - if (strpos($strName, '(') === false) { - $aReturn[] = [ - 'country' => IMDBHelper::cleanString($strName), - 'releasedate' => IMDBHelper::cleanString($aReturned[2][$i]) - ]; - } - } - - file_put_contents($sCacheFile, serialize($aReturn)); - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string The runtime of the movie or $sNotFound. - */ - public function getRuntime() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_RUNTIME, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string A list with the seasons or $sNotFound. - */ - public function getSeasons() - { - if (true === $this->isReady) { - $sMatch = $this->getSeasonsAsUrl(); - if (self::$sNotFound !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sTarget Add a target to the links? - * - * @return string A list with the linked seasons or $sNotFound. - */ - public function getSeasonsAsUrl($sTarget = '') - { - if (true === $this->isReady) { - $aMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_SEASONS); - $aReturn = []; - if (count($aMatch[1])) { - foreach (range(1, max($aMatch[1])) as $i => $sName) { - $aReturn[] = - '' . - $sName . - ''; - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound); - } - - /** - * @return string The sound mix of the movie or $sNotFound. - */ - public function getSoundMix() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_SOUND_MIX, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string The tagline of the movie or $sNotFound. - */ - public function getTagline() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_TAGLINE, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param bool $bForceLocal Try to return the original name of the movie. - * - * @return string The title of the movie or $sNotFound. - */ - public function getTitle($bForceLocal = false) - { - if (true === $this->isReady) { - if (true === $bForceLocal) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_TITLE_ORIG, 1); - if (false !== $sMatch && "" !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_TITLE, 1); - $sMatch = preg_replace('~\(\d{4}\)$~Ui', '', $sMatch); - if (false !== $sMatch && "" !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param bool $bEmbed Link to player directly? - * - * @return string The URL to the trailer of the movie or $sNotFound. - */ - public function getTrailerAsUrl($bEmbed = false) - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_TRAILER, 1); - if (false !== $sMatch) { - $sUrl = 'https://www.imdb.com/video/imdb/' . $sMatch . '/' . ($bEmbed ? 'player' : ''); - - return IMDBHelper::cleanString($sUrl); - } - } - - return self::$sNotFound; - } - - /** - * @return string The IMDb URL. - */ - public function getUrl() - { - if (true === $this->isReady) { - return IMDBHelper::cleanString(str_replace('reference', '', $this->sUrl)); - } - - return self::$sNotFound; - } - - /** - * @return string The user review of the movie or $sNotFound. - */ - public function getUserReview() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_USER_REVIEW, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string The votes of the movie or $sNotFound. - */ - public function getVotes() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_VOTES, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string A list with the writers or $sNotFound. - */ - public function getWriter() - { - if (true === $this->isReady) { - $sMatch = $this->getWriterAsUrl(); - if (self::$sNotFound !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @param string $sTarget Add a target to the links? - * - * @return string A list with the linked writers or $sNotFound. - */ - public function getWriterAsUrl($sTarget = '') - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_WRITER, 1); - $aMatch = IMDBHelper::matchRegex($sMatch, self::IMDB_NAME); - $aReturn = []; - if (count($aMatch[2])) { - foreach ($aMatch[2] as $i => $sName) { - $aReturn[] = - '' . - IMDBHelper::cleanString($sName) . - ''; - } - - return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); - } - } - - return self::$sNotFound; - } - - /** - * @return string The year of the movie or $sNotFound. - */ - public function getYear() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_YEAR, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } - - /** - * @return string The budget of the movie or $sNotFound. - */ - public function getBudget() - { - if (true === $this->isReady) { - $sMatch = IMDBHelper::matchRegex($this->sSource, self::IMDB_BUDGET, 1); - if (false !== $sMatch) { - return IMDBHelper::cleanString($sMatch); - } - } - - return self::$sNotFound; - } -} - -class IMDBHelper extends IMDB -{ - /** - * Regular expression helper. - * - * @param string $sContent The content to search in. - * @param string $sPattern The regular expression. - * @param null $iIndex The index to return. - * - * @return bool If no match was found. - * @return string If one match was found. - * @return array If more than one match was found. - */ - public static function matchRegex($sContent, $sPattern, $iIndex = null) - { - preg_match_all($sPattern, $sContent, $aMatches); - if ($aMatches === false) { - return false; - } - if ($iIndex !== null && is_int($iIndex)) { - if (isset($aMatches[$iIndex][0])) { - return $aMatches[$iIndex][0]; - } - - return false; - } - - return $aMatches; - } - - /** - * Preferred output in responses with multiple elements - * - * @param bool $bArrayOutput Native array or string with separators. - * @param string $sSeparator String separator. - * @param string $sNotFound Not found text. - * @param array $aReturn Original input. - * @param bool $bHaveMore Have more elements indicator. - * - * @return string|array Multiple results separated by selected separator string, or enclosed into native array. - */ - public static function arrayOutput($bArrayOutput, $sSeparator, $sNotFound, $aReturn = null, $bHaveMore = false) - { - if ($bArrayOutput) { - if ($aReturn == null || ! is_array($aReturn)) { - return []; - } - - if ($bHaveMore) { - $aReturn[] = '…'; - } - - return $aReturn; - } else { - if ($aReturn == null || ! is_array($aReturn)) { - return $sNotFound; - } - - foreach ($aReturn as $i => $value) { - if (is_array($value)) { - $aReturn[$i] = implode($sSeparator, $value); - } - } - - return implode($sSeparator, $aReturn) . (($bHaveMore) ? '…' : ''); - } - } - - /** - * @param string $sInput Input (eg. HTML). - * - * @return string Cleaned string. - */ - public static function cleanString($sInput) - { - $aSearch = [ - 'Full summary »', - 'Full synopsis »', - 'Add summary »', - 'Add synopsis »', - 'See more »', - 'See why on IMDbPro.', - "\n", - "\r" - ]; - $aReplace = [ - '', - '', - '', - '', - '', - '', - '', - '' - ]; - $sInput = str_replace('', ' | ', $sInput); - $sInput = strip_tags($sInput); - $sInput = str_replace(' ', ' ', $sInput); - $sInput = str_replace($aSearch, $aReplace, $sInput); - $sInput = html_entity_decode($sInput, ENT_QUOTES | ENT_HTML5); - $sInput = preg_replace('/\s+/', ' ', $sInput); - $sInput = trim($sInput); - $sInput = rtrim($sInput, ' |'); - - return ($sInput ? trim($sInput) : self::$sNotFound); - } - - /** - * @param string $sText The long text. - * @param int $iLength The maximum length of the text. - * - * @return string The shortened text. - */ - public static function getShortText($sText, $iLength = 100) - { - if (mb_strlen($sText) <= $iLength) { - return $sText; - } - - list($sShort) = explode("\n", wordwrap($sText, $iLength - 1)); - - if (substr($sShort, -1) !== '.') { - return $sShort . '…'; - } - - return $sShort; - } - - /** - * @param string $sUrl The URL to the image to download. - * @param int $iId The ID of the movie. - * - * @return string Local path. - */ - public static function saveImage($sUrl, $iId) - { - if (preg_match('~title_addposter.jpg|imdb-share-logo.png~', $sUrl)) { - return 'posters/not-found.jpg'; - } - - $sFilename = dirname(__FILE__) . '/posters/' . $iId . '.jpg'; - if (file_exists($sFilename)) { - return 'posters/' . $iId . '.jpg'; - } - - $aCurlInfo = self::runCurl($sUrl, true); - $sData = $aCurlInfo['contents']; - if (false === $sData) { - return 'posters/not-found.jpg'; - } - - $oFile = fopen($sFilename, 'x'); - fwrite($oFile, $sData); - fclose($oFile); - - return 'posters/' . $iId . '.jpg'; - } - - /** - * @param string $sUrl The URL to fetch. - * @param bool $bDownload Download? - * - * @return bool|mixed Array on success, false on failure. - */ - public static function runCurl($sUrl, $bDownload = false) - { - $oCurl = curl_init($sUrl); - curl_setopt_array($oCurl, - [ - CURLOPT_BINARYTRANSFER => ($bDownload ? true : false), - CURLOPT_CONNECTTIMEOUT => self::IMDB_TIMEOUT, - CURLOPT_ENCODING => '', - CURLOPT_FOLLOWLOCATION => 0, - CURLOPT_FRESH_CONNECT => 0, - CURLOPT_HEADER => ($bDownload ? false : true), - CURLOPT_HTTPHEADER => [ - 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'Accept-Charset: utf-8, iso-8859-1;q=0.5', - 'Accept-Language: ' . self::IMDB_LANG - ], - CURLOPT_REFERER => 'https://www.imdb.com', - CURLOPT_RETURNTRANSFER => 1, - CURLOPT_SSL_VERIFYHOST => 0, - CURLOPT_SSL_VERIFYPEER => 0, - CURLOPT_TIMEOUT => self::IMDB_TIMEOUT, - CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0', - CURLOPT_VERBOSE => 0 - ]); - $sOutput = curl_exec($oCurl); - $aCurlInfo = curl_getinfo($oCurl); - curl_close($oCurl); - $aCurlInfo['contents'] = $sOutput; - - if (200 !== $aCurlInfo['http_code'] && 302 !== $aCurlInfo['http_code']) { - if (true === self::IMDB_DEBUG) { - echo '
cURL returned wrong HTTP code “' . $aCurlInfo['http_code'] . '”, aborting.
'; - } - - return false; - } - - return $aCurlInfo; - } - - /** - * @param string $sUrl The URL to the image to download. - * @param int $cId The cast ID of the actor. - * - * @return string Local path. - */ - public static function saveImageCast($sUrl, $cId) - { - if ( ! preg_match('~http~', $sUrl)) { - return 'cast/not-found.jpg'; - } - - $sFilename = dirname(__FILE__) . '/cast/' . $cId . '.jpg'; - if (file_exists($sFilename)) { - return 'cast/' . $cId . '.jpg'; - } - - $aCurlInfo = self::runCurl($sUrl, true); - $sData = $aCurlInfo['contents']; - if (false === $sData) { - return 'cast/not-found.jpg'; - } - - $oFile = fopen($sFilename, 'x'); - fwrite($oFile, $sData); - fclose($oFile); - - return 'cast/' . $cId . '.jpg'; - } -} diff --git a/plugin/IMDbScrape/posters/not-found.jpg b/plugin/IMDbScrape/posters/not-found.jpg deleted file mode 100644 index 60dbbee78..000000000 Binary files a/plugin/IMDbScrape/posters/not-found.jpg and /dev/null differ diff --git a/plugin/ShareSocialButtonsOnEmbed/ShareSocialButtonsOnEmbed.php b/plugin/ShareSocialButtonsOnEmbed/ShareSocialButtonsOnEmbed.php deleted file mode 100644 index f670afd30..000000000 --- a/plugin/ShareSocialButtonsOnEmbed/ShareSocialButtonsOnEmbed.php +++ /dev/null @@ -1,34 +0,0 @@ -(Deprecated, will be removed next version) Enable Or disable Share Social Buttons on Embed videos"; - } - - public function getName() { - return "ShareSocialButtonsOnEmbed"; - } - - public function getUUID() { - return "c63ae9e3-bf01-4f76-9d7e-b3ad7fd92e3e"; - } - - public function getFooterCode() { - global $global, $video, $isEmbed; - if(empty($isEmbed)){ - return ""; - } - include 'script.php'; - } -} diff --git a/plugin/ShareSocialButtonsOnEmbed/script.php b/plugin/ShareSocialButtonsOnEmbed/script.php deleted file mode 100644 index 74bba397d..000000000 --- a/plugin/ShareSocialButtonsOnEmbed/script.php +++ /dev/null @@ -1,140 +0,0 @@ - - - \ No newline at end of file diff --git a/plugin/YouTube/YouTube.php b/plugin/YouTube/YouTube.php deleted file mode 100644 index ba2b03fa2..000000000 --- a/plugin/YouTube/YouTube.php +++ /dev/null @@ -1,123 +0,0 @@ -(Deprecated, will be removed in next version) Make the first page works as a YouTube"; - } - - public function getName() { - return "YouTube"; - } - - public function getUUID() { - return "youu05bf-3570-4b1f-977a-fd0e5cabtube"; - } - - public function getPluginVersion() { - return "1.0"; - } - - public function getHeadCode() { - global $global, $sidebarStyle; - $obj = $this->getDataObject(); - // preload image - $js = ""; - $css = ''; - if(!empty($obj->playVideoOnFullscreen) && !empty($_GET['videoName'])){ - $css .= ''; - } - if(!empty($obj->playVideoOnFullscreen)){ - $css .= ''; - } - - $sidebarStyle = ($this->menuIsOpen())?"/**/":"display: none;"; - - return $js.$css; - } - public function getEmptyDataObject() { - global $global; - $obj = new stdClass(); - - $obj->hidePrivateVideos = false; - $obj->BigVideo = true; - $obj->Description = false; - $obj->CategoryDescription = false; - $obj->Trending = true; - $obj->TrendingCustomTitle = ""; - $obj->TrendingRowCount = 12; - $obj->DateAdded = true; - $obj->DateAddedCustomTitle = ""; - $obj->DateAddedRowCount = 12; - $obj->MostWatched = true; - $obj->MostWatchedCustomTitle = ""; - $obj->MostWatchedRowCount = 12; - $obj->MostPopular = true; - $obj->MostPopularCustomTitle = ""; - $obj->MostPopularRowCount = 12; - $obj->SortByName = false; - $obj->SortByNameCustomTitle = ""; - $obj->SortByNameRowCount = 12; - $obj->SubscribedChannels = true; - $obj->SubscribedChannelsRowCount = 12; - $obj->Categories = false; - $obj->CategoriesRowCount = 12; - $obj->sortReverseable = false; - $obj->SubCategorys = false; - $obj->showTags = true; - $obj->searchOnChannels = true; - $obj->searchOnChannelsRowCount = 12; - $obj->playVideoOnFullscreen = false; - $obj->playVideoOnBrowserFullscreen = false; - $obj->filterUserChannel = false; - return $obj; - } - - public function getHelp(){ - if(User::isAdmin()){ - return "

YouTube options (admin)

Option-nameDefaultDescription
BigVideocheckedCreate a big preview with a direct description on top
DateAdded,MostPopular,MostWatched,SortByNamechecked,checked,checked,uncheckedMetacategories
SubCategorysunchecked Enable a view for subcategories on top
DescriptionuncheckedEnable a small button for show the description
"; - } - return ""; - } - public function getFirstPage(){ - global $global; - return $global['systemRootPath'].'plugin/YouTube/view/modeYouTube.php'; - } - - public function getFooterCode() { - $obj = $this->getDataObject(); - global $global; - - $js = ''; - if(!empty($obj->playVideoOnFullscreen)){ - $js = ''; - } - if(!empty($obj->playVideoOnBrowserFullscreen)){ - $js = ''; - } - return $js; - } - - public function navBar() { - global $global,$includeDefaultNavBar; - //include $global['systemRootPath'] . 'plugin/YouTube/view/navbar.php'; - //$includeDefaultNavBar = false; - } - - public function getStart() { - global $global; - $global['bodyClass'] = ($this->menuIsOpen())?"youtube":""; - - } - - private function menuIsOpen(){ - return (empty($_COOKIE['youTubeMenuIsOpened']) || $_COOKIE['youTubeMenuIsOpened']==="false")?false:true; - } -} diff --git a/plugin/YouTube/script.js b/plugin/YouTube/script.js deleted file mode 100644 index 784da18be..000000000 --- a/plugin/YouTube/script.js +++ /dev/null @@ -1,55 +0,0 @@ -$(document).ready(function () { - $(document).off('click.sidebar'); - $('#buttonMenu').off('click.sidebar'); - - $('#buttonMenu').on("click.sidebar", function (event) { - event.stopPropagation(); - if ($('body').hasClass('youtube')) { - closeYouTubeMenu(); - } else { - openYouTubeMenu(); - } - }); - //$("#buttonSearch, #buttonMyNavbar").off('click'); - if ($(window).width() < 1500) { - youTubeMenuIsOpened = Cookies.get('youTubeMenuIsOpened'); - if(typeof youTubeMenuIsOpened === 'undefined'){ - $('#buttonMenu').trigger("click"); - } - } - $(window).resize(function () { - if ($(window).width() < 1500) { - if ($('body').hasClass('youtube')) { - $('#buttonMenu').trigger("click"); - } - } else { - if (!$('body').hasClass('youtube')) { - $('#buttonMenu').trigger("click"); - } - } - }); -}); - -function closeYouTubeMenu() { - console.log('closeYouTubeMenu'); - $('body').removeClass('youtube'); - $("#sidebar").toggle("slide"); - $('#myNavbar').removeClass("in"); - $('#mysearch').removeClass("in"); - Cookies.set('youTubeMenuIsOpened', false, { - path: '/', - expires: 365 - }); -} - -function openYouTubeMenu() { - console.log('openYouTubeMenu'); - $('body').addClass('youtube'); - $("#sidebar").toggle("slide"); - $('#myNavbar').removeClass("in"); - $('#mysearch').removeClass("in"); - Cookies.set('youTubeMenuIsOpened', true, { - path: '/', - expires: 365 - }); -} \ No newline at end of file diff --git a/plugin/YouTube/style.css b/plugin/YouTube/style.css deleted file mode 100644 index 1a922f7bc..000000000 --- a/plugin/YouTube/style.css +++ /dev/null @@ -1,261 +0,0 @@ -@import "../Gallery/style.css"; -.YouTube .duration { - position: absolute; - background: rgba(0, 0, 0, 0.6)!important; - padding: 3px; - color: #FFF; - top: 5px; - left: 25px; - font-size: 0.9em; - border-radius: 5px; -} -.YouTube h2, -.videosDetails .title { - font-size: 1em; - margin: 0; - padding: 0; - overflow: hidden; - text-overflow: ellipsis; - display: -webkit-box; - line-height: 16px; /* fallback */ - max-height: 32px; /* fallback */ - min-height: 32px; /* fallback */ - -webkit-line-clamp: 2; /* number of lines to show */ - - -webkit-box-orient: vertical; -} -.YouTube .watch-view-count { - font-size: 0.8em; - font-weight: normal; - border: 0; - margin: 0; - padding: 0; -} -.YouTubeVideo .group { - overflow: hidden; - text-overflow: ellipsis; -} - -.mainArea{ - padding: 15px; -} - -h3.YouTubeTitle{ - padding: 15px 5px; -} - -.aspectRatio16_9 { - position: relative; - display: block; - width: 100%; - height: 0; - padding-bottom: 56.25%; - overflow: hidden; - background-image: url(../../view/img/video-placeholder.png); - background-size: cover; -} - -.aspectRatio16_9 img{ - text-indent:-9999px; - width: 100%; - display: block; - margin-left: auto; - margin-right: auto; -} - -.thumbsGIF{ - text-indent:-9999px; - width: 100%; - margin-left: auto; - margin-right: auto; -} - -.firstRow{ - margin-bottom: 10px; - padding-bottom: 25px; - border-bottom: solid 1px #EEE; -} - -.aligned-row { - overflow: hidden; - border-bottom: solid 1px #EEE; - margin-bottom: 10px; - padding-bottom: 10px; -} - -.galeryDetails div{ - float: left; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - padding-right: 5px; - font-size: 0.7em; -} - -.firstRow .galeryDetails div{ - font-size: 1em; -} - -.galeryDetails div.userName{ - width: 100%; -} -.fixPadding{ - padding: 0 5px; -} - -.popover-content, .popover-content>div{ - white-space: normal !important; - width: auto; - color: inherit !important; -} -.popover-content>div{ - overflow-y: auto; - height: 140px; -} -.aligned-row{ - overflow: visible !important; -} - -.mainAreaDescription{ - position:relative; - height:100%; - width: 110%; - padding-right: 10%; - overflow-x:hidden; - overflow-y:scroll; - max-height: 17vw; -} -.mainAreaDescriptionContainer{ - position: relative; - overflow: hidden; -} -a.h6{ - text-decoration: none !important; -} - -.popover-title { - color: black; - font-size: 1em; -} - -.popover-content{ - color: black !important; - font-size: 0.8em; -} - -.YouTube .label{ - font-size: 100%; - border-radius: 0; -} - -.YouTubeTitle a.btn-default:hover{ - background-color: transparent; -} - - -.ytd-shelf-renderer { - color: #000; - display: block; - max-height: 2rem; - overflow: hidden; - font-size: 1.6rem; - font-weight: 500; - line-height: 2rem; -} - -#sidebar{ - - background-color: #f5f5f5; -} -#sideBarContainer{ - padding: 0; -} - -#sideBarContainer li a { - color: #0a0a0a; - padding: 10px 20px; - -} -#sideBarContainer li span:not(.badge), #sideBarContainer li i { - color: #888; - margin-right: 20px; - font-size: 1.4em; -} -#sideBarContainer ul li h3, #sideBarContainer ul li h2 { - color: #555; - font-weight: bolder; - text-transform: uppercase; - font-size: 1.3rem; -} -#sideBarContainer .btn { - background: transparent; - border-width: 0; - text-align: left; - border-radius: 0; -} - -#sideBarContainer .btn:focus, #sideBarContainer .btn:hover{ - text-decoration: none; - background-color: #eee; -} -#sideBarContainer .selected, .rightProfile .selected { - background-color:#DDD; -} - -.rightProfile li a:focus span:not(.badge), .rightProfile li a:hover span:not(.badge), -.rightProfile li .selected i, .rightProfile li .selected span:not(.badge), -#sideBarContainer li a:focus span:not(.badge), #sideBarContainer li a:hover span:not(.badge), -#sideBarContainer li a:focus i, #sideBarContainer li a:hover i, -#sideBarContainer .selected i, #sideBarContainer .selected span:not(.badge){ - color: #ff0000; -} - -.galleryTitle a{ - background-color: transparent; -} -@media screen and (min-width: 768px) { - body.youtube{ - margin-left: 300px; - } -} -body{ - transition: all 0.3s ease-in-out; - background-color: #fafafa; -} -.navbar{ - background-color: #fff; - color: hsl(0, 0%, 63%); -} -#searchForm .btn{ - background: #f0f0f0; - border: 1px solid #ccc; - border-top-left-radius: 0; - border-bottom-left-radius: 0; - color: #333; -} -#sideBarContainer .navbar{ - background: transparent; -} - -.navbar .btn{ - background-color: transparent; - border-width: 0; - color: hsl(0, 0%, 63%); -} - -.fixPadding{ - padding: 0 2px; -} -#buttonMenu { - width: 36px; - text-align: center; - padding: 6px 0; - border-radius: 18px; -} -#rightProfileButton{ - margin: 6px; - padding: 3px; - background-color: transparent; - border-width: 0; - border-radius: 16px; -} \ No newline at end of file diff --git a/plugin/YouTube/view/BigVideo.php b/plugin/YouTube/view/BigVideo.php deleted file mode 100644 index 24bfb41a1..000000000 --- a/plugin/YouTube/view/BigVideo.php +++ /dev/null @@ -1,139 +0,0 @@ -BigVideo && empty($_GET['showOnly'])) { - $name = User::getNameIdentificationById($video['users_id']); - if (empty($get)) { - $get = array(); - } - ?> -
-
- -
- -

-
-
-

-
-
-
- - - - - - - - - showTags)) { - $video['tags'] = Video::getTags($video['id']); - if (!empty($video['tags'])) { - foreach ($video['tags'] as $value2) { - if (!empty($value2->label) && $value2->label === __("Group")) { - ?>text; ?> -
- - doNotDisplayViews)) { - ?> -
- - -
- -
- - -
-
- - - - -
- -
- -
- - - -
- - -
- -
-
-
-
- - - SubCategorys)) { - ?> - CategoryDescription) && (!empty($_GET['catName']))) { ?> -

-

- SubCategorys) && (!empty($_GET['catName']))) { - unset($_POST['rowCount']); - if (!empty($currentCat)) { - $childCategories = Category::getChildCategories($currentCat['id']); - $parentCat = Category::getCategory($currentCat['parentId']); - // -1 is a personal workaround only - if ((empty($parentCat)) && (($currentCat['parentId'] == "0") || ($currentCat['parentId'] == "-1"))) { - if (!empty($_GET['catName'])) { - ?> -
- - - - -
-
- -
- - - - -
-
- -
- -
- -
-

- - -

-
-
'; - } - $countCols ++; - unset($_GET['catName']); - ?> - - - -
-
- sortReverseable) { - if (strpos($_SERVER['REQUEST_URI'], "?") != false) { - $orderString = $_SERVER['REQUEST_URI'] . "&"; - } else { - $orderString = $_SERVER['REQUEST_URI'] . "/?"; - } - $orderString = str_replace("&&", "&", $orderString); - $orderString = str_replace("//", "/", $orderString); -} -$video = Video::getVideo("", "viewable", !$objYTube->hidePrivateVideos, false, true); -if (empty($video)) { - $video = Video::getVideo("", "viewable", !$objYTube->hidePrivateVideos, true); -} -if (empty($_GET['page'])) { - $_GET['page'] = 1; -} else { - $_GET['page'] = intval($_GET['page']); -} -$total = 0; -$totalPages = 0; -$url = ''; -$args = ''; -if (strpos($_SERVER['REQUEST_URI'], "?") != false) { - $args = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], "?"), strlen($_SERVER['REQUEST_URI'])); -} -if (strpos($_SERVER['REQUEST_URI'], "/cat/") === false) { - $url = $global['webSiteRootURL'] . "page/"; -} else { - $url = $global['webSiteRootURL'] . "cat/" . $video['clean_category'] . "/page/"; -} -$contentSearchFound = false; -?> - - - - <?php - echo $config->getWebSiteTitle(); - ?> - - - - - -
-
- -
-
- -
- searchOnChannels && !empty($_GET['search'])) { - $channels = User::getAllUsers(true); - clearSearch(); - foreach ($channels as $value) { - $contentSearchFound = true; - createChannelItem($value['id'], $value['photoURL'], $value['identification']); - } - reloadSearch(); - } - - if (!empty($video)) { - $contentSearchFound = true; - $img_portrait = ($video['rotation'] === "90" || $video['rotation'] === "270") ? "img-portrait" : ""; - if (empty($_GET['search'])) { - include $global['systemRootPath'] . 'plugin/YouTube/view/BigVideo.php'; - } - ?> -
- -
- - - - - - Trending) { - createGallery(!empty($objYTube->TrendingCustomTitle) ? $objYTube->TrendingCustomTitle : __("Trending"), 'trending', $objYTube->TrendingRowCount, 'TrendingOrder', "zyx", "abc", $orderString, "ASC", !$objYTube->hidePrivateVideos); - } - if ($objYTube->SortByName) { - createGallery(!empty($objYTube->SortByNameCustomTitle) ? $objYTube->SortByNameCustomTitle : __("Sort by name"), 'title', $objYTube->SortByNameRowCount, 'sortByNameOrder', "zyx", "abc", $orderString, "ASC", !$objYTube->hidePrivateVideos); - } - if ($objYTube->DateAdded) { - createGallery(!empty($objYTube->DateAddedCustomTitle) ? $objYTube->DateAddedCustomTitle : __("Date added"), 'created', $objYTube->DateAddedRowCount, 'dateAddedOrder', __("newest"), __("oldest"), $orderString, "DESC", !$objYTube->hidePrivateVideos); - } - if ($objYTube->MostWatched) { - createGallery(!empty($objYTube->MostWatchedCustomTitle) ? $objYTube->MostWatchedCustomTitle : __("Most watched"), 'views_count', $objYTube->MostWatchedRowCount, 'mostWatchedOrder', __("Most"), __("Fewest"), $orderString, "DESC", !$objYTube->hidePrivateVideos); - } - if ($objYTube->MostPopular) { - createGallery(!empty($objYTube->MostPopularCustomTitle) ? $objYTube->MostPopularCustomTitle : __("Most popular"), 'likes', $objYTube->MostPopularRowCount, 'mostPopularOrder', __("Most"), __("Fewest"), $orderString, "DESC", !$objYTube->hidePrivateVideos); - } - $catName = @$_GET['catName']; - if ($objYTube->Categories) { - echo ""; - unset($_POST['sort']); - unset($_POST['rowCount']); - $categories = Category::getAllCategories(); - $_REQUEST['rowCount'] = $objYTube->CategoriesRowCount; - $showAllVideos = false; - if (!empty($_GET['catName'])) { - $showAllVideos = true; - } - foreach ($categories as $value) { - if(!empty($catName) && $catName !== $value['clean_name']){ - continue; - } - $_GET['catName'] = $value['clean_name']; - unset($_POST['sort']); - $_POST['sort']['v.created'] = "DESC"; - $_POST['sort']['likes'] = "DESC"; - $videos = Video::getAllVideos("viewableNotUnlisted", false, true); - echo ""; - if (empty($videos)) { - continue; - } - ?> -
-

- - - - -

- -
- - - "; - } - if ($objYTube->SubscribedChannels && User::isLogged() && empty($_GET['showOnly'])) { - $channels = Subscribe::getSubscribedChannels(User::getId()); - foreach ($channels as $value) { - $_POST['disableAddTo'] = 0; - createChannelItem($value['users_id'], $value['photoURL'], $value['identification'], $objYTube->SubscribedChannelsRowCount); - } - } - unset($_POST['sort']); - ?> - - -
- - ! - . -
- -
-
-
- - - - -